<?php
$cwd= getcwd ();

chdir( dirname ( __FILE__ )."/../" );

require_once "./system/Settings.php";
require_once "./system/lang/".$Settings['language'].".php";
require_once "./system/lowLevelFunctions.php";
require_once "./system/db.class.php";
require_once "./system/DataSet.php";
require_once "./system/DataModel.php";
chdir($cwd);
//include all models:
$modelsLocation = "./models/";
$d =  dir($modelsLocation);
$allModels = Array();
while (false !== ($entry = $d->read()) ) {
	if ($entry != ".." && $entry != "."  && stripos($entry,".php")){
			require_once $modelsLocation . $entry;
			$className = substr($entry,0,  strrpos ( $entry, "."));
			if (!class_exists ( $className)){
				die(str_replace("[fileName]",$modelsLocation . $entry,$Lang['modelError']));
			}
			$allModels[]= $className;
	}
}

Class Server{
	public function HandleRemoteCall($instanceId,$method,$arguments){
		echo "$instanceId -> $method ( $arguments )";
	}
	public static function CreateJsModels(){
		global $allModels;
		foreach ($allModels as $model){
			$ModelTemplate = new $model();
			echo $ModelTemplate->CreateJsModel();
		}
	}
}

//new DataModel();

//$a = new MyModel();

//$data = new DataSet();


//$data->Load('MyModel',Array("id"=>25));
//print_r($data);

//$a->text = "1213312213233";

//echo nl2br($a->CreateJsModel());

//$a->Save();



//echo $Settings['coisa'];

?>
